test:main.cc
	g++ -g -Wall -o $@ $^ -pthread

# 测试目标：多次执行程序，检查输出行数
mutiple_test: test
	@for i in $$(seq 1 100); do\
		./test > output.tmp 2>&1;\
		lines=$$(wc -l < output.tmp);\
		if [ $$lines -lt 10000 ]; then\
			(echo "$$i : error : ";cat output.tmp;)|tee -a log.txt;\
		else\
			echo "$$i : successful";\
		fi; \
	done

	@(echo "End at [$$(date +'%Y-%m-%d %H:%M:%S')]";\
	echo "----------------------------------------------")>>log.txt
	@rm -f output.tmp

.PHONY:clean
clean:
	rm -f test mutiple_test

.PHONY:cmrt  #clean,make test and run
cmrt:
	make clean
	make
	./test

.PHONY:cmrm #clean,make mutiple_test and run
cmrm:
	make clean
	make mutiple_test